<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\common\logic;

/**
 * WalletRechargeType逻辑
 */
class CurrencyPay extends LogicBase
{
    
    /**
     * WalletRechargeType编辑
     */
    public function CurrencyPayEdit($data = [])
    {

        $validate_result = $this->validateCurr->scene('edit')->check($data);
        if (!$validate_result) {
            return [RESULT_ERROR, $this->validateCurr->getError()];
        }
        $url = url('CurrencyPayList');
        $result = $this->modelWalletRechargeType->setInfo($data);
        $handle_text = empty($data['id']) ? '新增' : '编辑';
        
        $result && action_log($handle_text, 'WalletRechargeType' . $handle_text );
        
        return $result ? [RESULT_SUCCESS, '操作成功', $url] : [RESULT_ERROR, $this->modelWalletRechargeType->getError()];
    }
    
    /**
     * 获取WalletRechargeType列表
     */
    public function getWalletRechargeTypeList($where = [], $field = 'a.*', $order = '')
    {
        
        $this->modelWalletRechargeType->alias('a');
        

        $where['a.' . DATA_STATUS_NAME] = ['neq', DATA_DELETE];

        
        return $this->modelWalletRechargeType->getList($where, $field, $order);
    }
    
    /**
     * 获取WalletRechargeType列表搜索条件
     */
    public function getWhere($data = [])
    {
        
        $where = [];
        
        !empty($data['search_data']) && $where['a.currency_id'] = ['like', '%'.$data['search_data'].'%'];
        
        return $where;
    }

    /**
     * WalletRechargeType删除
     */
    public function WalletRechargeTypeDel($where = [])
    {
        
        $result = $this->modelWalletRechargeType->deleteInfo($where);
        
        $result && action_log('删除', 'WalletRechargeType删除，where：' . http_build_query($where));
        
        return $result ? [RESULT_SUCCESS, 'WalletRechargeType删除成功'] : [RESULT_ERROR, $this->modelWalletRechargeType->getError()];
    }
}
